package com.yipei.business.controller;

import com.yipei.business.domain.MlSymbolsInfo;
import com.yipei.business.service.IMlSymbolsInfoService;
import com.yipei.common.annotation.Log;
import com.yipei.common.core.controller.BaseController;
import com.yipei.common.core.domain.AjaxResult;
import com.yipei.common.core.page.TableDataInfo;
import com.yipei.common.enums.BusinessType;
import com.yipei.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 标的信息Controller
 *
 * @author yipei
 * @date 2024-12-23
 */
@RestController
@RequestMapping("/business/symbolsinfo")
@Api(tags = "标的信息", description = "标的信息")
public class MlSymbolsInfoController extends BaseController {
    @Autowired
    private IMlSymbolsInfoService mlSymbolsInfoService;

    /**
     * 查询标的信息列表
     */
    //@PreAuthorize("@ss.hasPermi('business:symbolsinfo:list')")
    @ApiOperation("标的信息获取数据")
    @GetMapping("/list")
    public TableDataInfo list(MlSymbolsInfo mlSymbolsInfo) {
        startPage();
        List<MlSymbolsInfo> list = mlSymbolsInfoService.selectMlSymbolsInfoList(mlSymbolsInfo);
        return getDataTable(list);
    }

    /**
     * 导出标的信息列表
     */
    //@PreAuthorize("@ss.hasPermi('business:symbolsinfo:export')")
    @ApiOperation("标的信息导出数据")
    @Log(title = "标的信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MlSymbolsInfo mlSymbolsInfo) {
        List<MlSymbolsInfo> list = mlSymbolsInfoService.selectMlSymbolsInfoList(mlSymbolsInfo);
        ExcelUtil<MlSymbolsInfo> util = new ExcelUtil<MlSymbolsInfo>(MlSymbolsInfo.class);
        util.exportExcel(response, list, "标的信息数据");
    }

    /**
     * 获取标的信息详细信息
     */
    //@PreAuthorize("@ss.hasPermi('business:symbolsinfo:query')")
    @ApiOperation("标的信息通过ID获取数据")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(mlSymbolsInfoService.selectMlSymbolsInfoById(id));
    }

    /**
     * 新增标的信息
     */
    //@PreAuthorize("@ss.hasPermi('business:symbolsinfo:add')")
    @ApiOperation("标的信息新增数据")
    @Log(title = "标的信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MlSymbolsInfo mlSymbolsInfo) {
        return toAjax(mlSymbolsInfoService.insertMlSymbolsInfo(mlSymbolsInfo));
    }

    /**
     * 修改标的信息
     */
    //@PreAuthorize("@ss.hasPermi('business:symbolsinfo:edit')")
    @ApiOperation("标的信息修改数据")
    @Log(title = "标的信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MlSymbolsInfo mlSymbolsInfo) {
        return toAjax(mlSymbolsInfoService.updateMlSymbolsInfo(mlSymbolsInfo));
    }

    /**
     * 删除标的信息
     */
    //@PreAuthorize("@ss.hasPermi('business:symbolsinfo:remove')")
    @ApiOperation("标的信息删除数据")
    @Log(title = "标的信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(mlSymbolsInfoService.deleteMlSymbolsInfoByIds(ids));
    }


    @ApiOperation("标的信息获取数据")
    @GetMapping("/getlist")
    public TableDataInfo getlist(@RequestParam(name = "f12", required = true) String f12) {
        startPage();
        MlSymbolsInfo mlSymbolsInfo = new MlSymbolsInfo();
        mlSymbolsInfo.setSymbol(f12);
        List<MlSymbolsInfo> list = mlSymbolsInfoService.selectMlSymbolsInfoList(mlSymbolsInfo);
        return getDataTable(list);
    }
}
